home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / cbe.bst (.txt) < prev    next >
LaTeX Document  |  1992-07-19  |  24KB  |  927 lines

  1. %%% ====================================================================
  2. %%%  @BibTeX-style-file{
  3. %%%     author          = "Alan Rogers",
  4. %%%     version         = "1.1",
  5. %%%     date            = "1990",
  6. %%%     filename        = "cbe.bst",
  7. %%%     address         = "Dept of Anthropology, University of Utah,
  8. %%%                        Salt Lake City, UT 84112",
  9. %%%     checksum        = "13520 1161 3284 24308",
  10. %%%     email           = "rogers@anthro.utah.edu",
  11. %%%     supported       = "no",
  12. %%%     docstring       = "The file produces bibliographies more or
  13. %%%                        less in the Council of Biology Editors
  14. %%%                        format, which is used by Evolution,
  15. %%%                        American Naturalist, & lots of other
  16. %%%                        journals.  It was adapted from apalike.bst,
  17. %%%                        incorporating features of Sake J.
  18. %%%                        Hogeveen's `astron.bst'.
  19. %%%                        Usage: \documentstyle[astron]{...}
  20. %%%                        ...
  21. %%%                        \bibliographystyle{cbe}
  22. %%%                        ...
  23. %%%                        The \documentstyle command above invokes
  24. %%%                        Hogeveen's `astron.sty', which must be in
  25. %%%                        TeX's search path.
  26. %%%                        The modifications implement `\cite*{}',
  27. %%%                        which generates references in short form.
  28. %%%                        For example, `Rogers \cite*{...}' would
  29. %%%                        produce `Rogers (1992)'."
  30. %%%  }
  31. %%% ====================================================================
  32. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  33. % BibTeX `apalike' bibliography style (24-Jan-88 version)
  34. % Adapted from the `alpha' style, version 0.99a; for BibTeX version 0.99a.
  35. % Copyright (C) 1988, all rights reserved.
  36. % Copying of this file is allowed, provided that if you make any changes at all
  37. % you name it something other than `apalike.bst'.
  38. % This restriction helps ensure that all copies are identical.
  39. % Differences between this style and `alpha' are generally heralded by a `%'.
  40. % The file btxbst.doc has the documentation for alpha.bst.
  41. % This style should be used with the `apalike' LaTeX style (apalike.sty).
  42. % \cite's come out like "(Jones, 1986)" in the text but there are no labels
  43. % in the bibliography, and something like "(1986)" comes out immediately
  44. % after the author.  Author (and editor) names appear as last name, comma,
  45. % initials.  A `year' field is required for every entry, and so is either
  46. % an author (or in some cases, an editor) field or a key field.
  47. % Editorial note:
  48. % Many journals require a style like `apalike', but I strongly, strongly,
  49. % strongly recommend that you not use it if you have a choice---use something
  50. % like `plain' instead.  Mary-Claire van Leunen (A Handbook for Scholars,
  51. % Knopf, 1979) argues convincingly that a style like `plain' encourages better
  52. % writing than one like `apalike'.  Furthermore the strongest arguments for
  53. % using an author-date style like `apalike'---that it's "the most practical"
  54. % (The Chicago Manual of Style, University of Chicago Press, thirteenth
  55. % edition, 1982, pages 400--401)---fall flat on their face with the new
  56. % computer-typesetting technology.  For instance page 401 anachronistically
  57. % states "The chief disadvantage of [a style like `plain'] is that additions
  58. % or deletions cannot be made after the manuscript is typed without changing
  59. % numbers in both text references and list."  LaTeX sidesteps the disadvantage.
  60. % History:
  61. %   15-sep-86    (SK,OP)    Original version, by Susan King and Oren Patashnik.
  62. %   10-nov-86    (OP)    Truncated the sort.key$ string to the correct length
  63. %            in bib.sort.order to eliminate error message.
  64. %   24-jan-88    (OP)    Updated for BibTeX version 0.99a, from alpha.bst 0.99a;
  65. %            apalike now sorts by author, then year, then title;
  66. %            THIS `apalike' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
  67. ENTRY
  68.   { address
  69.     author
  70.     booktitle
  71.     chapter
  72.     edition
  73.     editor
  74.     howpublished
  75.     institution
  76.     journal
  77.     key
  78. %    month        not used in apalike
  79.     note
  80.     number
  81.     organization
  82.     pages
  83.     publisher
  84.     school
  85.     series
  86.     title
  87.     type
  88.     volume
  89.     year
  90.   { label extra.label sort.label }
  91. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  92. FUNCTION {init.state.consts}
  93. { #0 'before.all :=
  94.   #1 'mid.sentence :=
  95.   #2 'after.sentence :=
  96.   #3 'after.block :=
  97. STRINGS { s t }
  98. FUNCTION {output.nonnull}
  99. { 's :=
  100.   output.state mid.sentence =
  101.     { ", " * write$ }
  102.     { output.state after.block =
  103.     { add.period$ write$
  104.       newline$
  105.       "\newblock " write$
  106.     { output.state before.all =
  107.         'write$
  108.         { add.period$ " " * write$ }
  109.       if$
  110.       if$
  111.       mid.sentence 'output.state :=
  112.     }
  113.   if$
  114. FUNCTION {output}
  115. { duplicate$ empty$
  116.     'pop$
  117.     'output.nonnull
  118.   if$
  119. FUNCTION {output.check}
  120. { 't :=
  121.   duplicate$ empty$
  122.     { pop$ "empty " t * " in " * cite$ * warning$ }
  123.     'output.nonnull
  124.   if$
  125. %                    apalike needs this function because
  126. %                    the year has special punctuation;
  127. %                    apalike ignores the month
  128. FUNCTION {output.year.check}
  129. { year empty$
  130.     { "empty year in " cite$ * warning$ }
  131.     { write$
  132.       " " year * extra.label *
  133.       mid.sentence 'output.state :=
  134.     }
  135.   if$
  136. FUNCTION {output.bibitem}
  137. { newline$
  138.   "\bibitem[" write$
  139.   label write$
  140.   "]{" write$
  141.   cite$ write$
  142.   "}" write$
  143.   newline$
  144.   before.all 'output.state :=
  145. FUNCTION {fin.entry}
  146. { add.period$
  147.   write$
  148.   newline$
  149. FUNCTION {new.block}
  150. { output.state before.all =
  151.     'skip$
  152.     { after.block 'output.state := }
  153.   if$
  154. FUNCTION {new.sentence}
  155. { output.state after.block =
  156.     'skip$
  157.     { output.state before.all =
  158.     'skip$
  159.     { after.sentence 'output.state := }
  160.       if$
  161.     }
  162.   if$
  163. FUNCTION {not}
  164. {   { #0 }
  165.     { #1 }
  166.   if$
  167. FUNCTION {and}
  168. {   'skip$
  169.     { pop$ #0 }
  170.   if$
  171. FUNCTION {or}
  172. {   { pop$ #1 }
  173.     'skip$
  174.   if$
  175. FUNCTION {new.block.checkb}
  176. { empty$
  177.   swap$ empty$
  178.   and
  179.     'skip$
  180.     'new.block
  181.   if$
  182. FUNCTION {field.or.null}
  183. { duplicate$ empty$
  184.     { pop$ "" }
  185.     'skip$
  186.   if$
  187. FUNCTION {emphasize}
  188. { duplicate$ empty$
  189.     { pop$ "" }
  190.     { "{\em " swap$ * "}" * }
  191.   if$
  192. FUNCTION {smallcaps}
  193. { duplicate$ empty$
  194.     { pop$ "" }
  195.     { "{\sc " swap$ * "}" * }
  196.   if$
  197. INTEGERS { nameptr namesleft numnames }
  198. FUNCTION {format.names}
  199. { 's :=
  200.   #1 'nameptr :=
  201.   s num.names$ 'numnames :=
  202.   numnames 'namesleft :=
  203.     { namesleft #0 > }
  204.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % last name first
  205.       nameptr #1 >
  206.     { namesleft #1 >
  207.         { ", " * t * }
  208.         { numnames #2 >
  209.         { "," * }
  210.         'skip$
  211.           if$
  212.           t "others" =
  213.         { " et~al." * }
  214.         { " and " * t * }
  215.           if$
  216.         }
  217.       if$
  218.       if$
  219.       nameptr #1 + 'nameptr :=
  220.       namesleft #1 - 'namesleft :=
  221.     }
  222.   while$
  223. FUNCTION {format.editor.names}
  224. { 's :=
  225.   #1 'nameptr :=
  226.   s num.names$ 'numnames :=
  227.   numnames 'namesleft :=
  228.     { namesleft #0 > }
  229.     { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't :=   % last name first
  230.       nameptr #1 >
  231.     { namesleft #1 >
  232.         { ", " * t * }
  233.         { numnames #2 >
  234.         { "," * }
  235.         'skip$
  236.           if$
  237.           t "others" =
  238.         { " et~al." * }
  239.         { " and " * t * }
  240.           if$
  241.         }
  242.       if$
  243.       if$
  244.       nameptr #1 + 'nameptr :=
  245.       namesleft #1 - 'namesleft :=
  246.     }
  247.   while$
  248. FUNCTION {format.authors}
  249. { author empty$
  250.     { "" }
  251.     { author format.names smallcaps }
  252.   if$
  253. FUNCTION {format.key}            % this function is just for apalike
  254. { empty$
  255.     { key field.or.null }
  256.     { "" }
  257.   if$
  258. FUNCTION {format.editors}
  259. { editor empty$
  260.     { "" }
  261.     { editor format.editor.names
  262.       editor num.names$ #1 >
  263.     { " (eds.)" * }
  264.     { " (ed.)" * }
  265.       if$
  266.     }
  267.   if$
  268. FUNCTION {format.title}
  269. { title empty$
  270.     { "" }
  271.     { title "t" change.case$ }
  272.   if$
  273. FUNCTION {n.dashify}
  274. { 't :=
  275.     { t empty$ not }
  276.     { t #1 #1 substring$ "-" =
  277.     { t #1 #2 substring$ "--" = not
  278.         { "--" *
  279.           t #2 global.max$ substring$ 't :=
  280.         }
  281.         {   { t #1 #1 substring$ "-" = }
  282.         { "-" *
  283.           t #2 global.max$ substring$ 't :=
  284.           while$
  285.         }
  286.       if$
  287.     { t #1 #1 substring$ *
  288.       t #2 global.max$ substring$ 't :=
  289.       if$
  290.     }
  291.   while$
  292. FUNCTION {format.btitle}
  293. { title %emphasize
  294. FUNCTION {tie.or.space.connect}
  295. { duplicate$ text.length$ #3 <
  296.     { "~" }
  297.     { " " }
  298.   if$
  299.   swap$ * *
  300. FUNCTION {either.or.check}
  301. { empty$
  302.     'pop$
  303.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  304.   if$
  305. FUNCTION {format.bvolume}
  306. { volume empty$
  307.     { "" }
  308.     { "volume" volume tie.or.space.connect
  309.       series empty$
  310.     'skip$
  311.     { " of " * series emphasize * }
  312.       if$
  313.       "volume and number" number either.or.check
  314.     }
  315.   if$
  316. FUNCTION {format.number.series}
  317. { volume empty$
  318.     { number empty$
  319.     { series field.or.null }
  320.     { output.state mid.sentence =
  321.         { "number" }
  322.         { "Number" }
  323.       if$
  324.       number tie.or.space.connect
  325.       series empty$
  326.         { "there's a number but no series in " cite$ * warning$ }
  327.         { " in " * series * }
  328.       if$
  329.       if$
  330.     }
  331.     { "" }
  332.   if$
  333. FUNCTION {format.edition}
  334. { edition empty$
  335.     { "" }
  336.     { output.state mid.sentence =
  337.     { edition "l" change.case$ " edition" * }
  338.     { edition "t" change.case$ " edition" * }
  339.       if$
  340.     }
  341.   if$
  342. INTEGERS { multiresult }
  343. FUNCTION {multi.page.check}
  344. { 't :=
  345.   #0 'multiresult :=
  346.     { multiresult not
  347.       t empty$ not
  348.       and
  349.     }
  350.     { t #1 #1 substring$
  351.       duplicate$ "-" =
  352.       swap$ duplicate$ "," =
  353.       swap$ "+" =
  354.       or or
  355.     { #1 'multiresult := }
  356.     { t #2 global.max$ substring$ 't := }
  357.       if$
  358.     }
  359.   while$
  360.   multiresult
  361. FUNCTION {format.pages}
  362. { pages empty$
  363.     { "" }
  364.     { pages multi.page.check
  365.     { "pp." pages n.dashify tie.or.space.connect }
  366.     { "p." pages tie.or.space.connect }
  367.       if$
  368.     }
  369.   if$
  370. FUNCTION {format.vol.num.pages}
  371. { volume field.or.null
  372.   pages empty$
  373.     'skip$
  374.     { duplicate$ empty$
  375.     { pop$ format.pages }
  376.     { ":" * pages n.dashify * }
  377.       if$
  378.     }
  379.   if$
  380. FUNCTION {format.chapter.pages}
  381. { chapter empty$
  382.     { "" }
  383.     { type empty$
  384.     { "chapter" }
  385.     { type "l" change.case$ }
  386.       if$
  387.       chapter tie.or.space.connect
  388.     }
  389.   if$
  390. FUNCTION {format.in.ed.booktitle}
  391. { booktitle empty$
  392.     { "" }
  393.     { editor empty$
  394. %    { "{\em In} " booktitle emphasize * }
  395. %    { "{\em In} " format.editors * ", " * booktitle emphasize * }
  396.     { "{\em In} " booktitle * }
  397.     { "{\em In} " format.editors * ", " * booktitle * }
  398.       if$
  399.     }
  400.   if$
  401. FUNCTION {format.thesis.type}
  402. { type empty$
  403.     'skip$
  404.     { pop$
  405.       type "t" change.case$
  406.     }
  407.   if$
  408. FUNCTION {format.tr.number}
  409. { type empty$
  410.     { "Technical Report" }
  411.     'type
  412.   if$
  413.   number empty$
  414.     { "t" change.case$ }
  415.     { number tie.or.space.connect }
  416.   if$
  417. FUNCTION {format.article.crossref}
  418. { "In"                            % this is for apalike
  419.   " \cite{" * crossref * "}" *
  420. FUNCTION {format.book.crossref}
  421. { volume empty$
  422.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  423.       "In "
  424.     }
  425.     { "Volume" volume tie.or.space.connect
  426.       " of " *
  427.     }
  428.   if$
  429.   "\cite{" * crossref * "}" *                % this is for apalike
  430. FUNCTION {format.incoll.inproc.crossref}
  431. { "In"                            % this is for apalike
  432.   " \cite{" * crossref * "}" *
  433. FUNCTION {article}
  434. { output.bibitem
  435.   format.authors "author" output.check
  436.   author format.key output                % special for
  437.   output.year.check                    % apalike
  438.   new.block
  439.   format.title "title" output.check
  440.   new.block
  441.   crossref missing$
  442.     { journal emphasize " " * format.vol.num.pages * output
  443.     }
  444.     { format.article.crossref output.nonnull
  445.       format.pages output
  446.     }
  447.   if$
  448.   new.block
  449.   note output
  450.   fin.entry
  451. FUNCTION {book}
  452. { output.bibitem
  453.   author empty$
  454.     { format.editors "author and editor" output.check
  455.       editor format.key output
  456.     }
  457.     { format.authors output.nonnull
  458.       crossref missing$
  459.     { "author and editor" editor either.or.check }
  460.     'skip$
  461.       if$
  462.     }
  463.   if$
  464.   output.year.check                % special for apalike
  465.   new.block
  466.   format.btitle "title" output.check
  467.   crossref missing$
  468.     { format.bvolume output
  469.       new.block
  470.       format.number.series output
  471.       new.sentence
  472.       publisher "publisher" output.check
  473.       address output
  474.     }
  475.     { new.block
  476.       format.book.crossref output.nonnull
  477.     }
  478.   if$
  479.   format.edition output
  480.   new.block
  481.   note output
  482.   fin.entry
  483. FUNCTION {booklet}
  484. { output.bibitem
  485.   format.authors output
  486.   author format.key output                % special for
  487.   output.year.check                    % apalike
  488.   new.block
  489.   format.title "title" output.check
  490.   new.block
  491.   howpublished output
  492.   address output
  493.   new.block
  494.   note output
  495.   fin.entry
  496. FUNCTION {inbook}
  497. { output.bibitem
  498.   author empty$
  499.     { format.editors "author and editor" output.check
  500.       editor format.key output
  501.     }
  502.     { format.authors output.nonnull
  503.       crossref missing$
  504.     { "author and editor" editor either.or.check }
  505.     'skip$
  506.       if$
  507.     }
  508.   if$
  509.   output.year.check                % special for apalike
  510.   new.block
  511.   format.btitle "title" output.check
  512.   crossref missing$
  513.     { format.bvolume output
  514.       format.chapter.pages "chapter and pages" output.check
  515.       new.block
  516.       format.number.series output
  517.       new.sentence
  518.       publisher "publisher" output.check
  519.       address output
  520.     }
  521.     { format.chapter.pages "chapter and pages" output.check
  522.       new.block
  523.       format.book.crossref output.nonnull
  524.     }
  525.   if$
  526.   format.edition output
  527.   new.block
  528.   note output
  529.   fin.entry
  530. FUNCTION {incollection}
  531. { output.bibitem
  532.   format.authors "author" output.check
  533.   author format.key output                % special for
  534.   output.year.check                    % apalike
  535.   new.block
  536.   format.title "title" output.check
  537.   format.pages output
  538.   new.block
  539.   crossref missing$
  540.     { format.in.ed.booktitle "booktitle" output.check
  541.       format.bvolume output
  542.       format.number.series output
  543.       format.chapter.pages output
  544.       new.sentence
  545.       publisher "publisher" output.check
  546.       address output
  547.       format.edition output
  548.     }
  549.     { format.incoll.inproc.crossref output.nonnull
  550.       format.chapter.pages output
  551.     }
  552.   if$
  553.   new.block
  554.   note output
  555.   fin.entry
  556. FUNCTION {inproceedings}
  557. { output.bibitem
  558.   format.authors "author" output.check
  559.   author format.key output                % special for
  560.   output.year.check                    % apalike
  561.   new.block
  562.   format.title "title" output.check
  563.   new.block
  564.   crossref missing$
  565.     { format.in.ed.booktitle "booktitle" output.check
  566.       format.bvolume output
  567.       format.number.series output
  568.       format.pages output
  569.       address output                    % for apalike
  570.       new.sentence                    % there's no year
  571.       organization output                % here so things
  572.       publisher output                    % are simpler
  573.     }
  574.     { format.incoll.inproc.crossref output.nonnull
  575.       format.pages output
  576.     }
  577.   if$
  578.   new.block
  579.   note output
  580.   fin.entry
  581. FUNCTION {conference} { inproceedings }
  582. FUNCTION {manual}
  583. { output.bibitem
  584.   format.authors output
  585.   author format.key output                % special for
  586.   output.year.check                    % apalike
  587.   new.block
  588.   format.btitle "title" output.check
  589.   organization address new.block.checkb
  590.   organization output
  591.   address output
  592.   format.edition output
  593.   new.block
  594.   note output
  595.   fin.entry
  596. FUNCTION {mastersthesis}
  597. { output.bibitem
  598.   format.authors "author" output.check
  599.   author format.key output                % special for
  600.   output.year.check                    % apalike
  601.   new.block
  602.   format.title "title" output.check
  603.   new.block
  604.   "Master's thesis" format.thesis.type output.nonnull
  605.   school "school" output.check
  606.   address output
  607.   new.block
  608.   note output
  609.   fin.entry
  610. FUNCTION {misc}
  611. { output.bibitem
  612.   format.authors output
  613.   author format.key output                % special for
  614.   output.year.check                    % apalike
  615.   new.block
  616.   format.title output
  617.   new.block
  618.   howpublished output
  619.   new.block
  620.   note output
  621.   fin.entry
  622. FUNCTION {phdthesis}
  623. { output.bibitem
  624.   format.authors "author" output.check
  625.   author format.key output                % special for
  626.   output.year.check                    % apalike
  627.   new.block
  628.   format.btitle "title" output.check
  629.   new.block
  630.   "PhD thesis" format.thesis.type output.nonnull
  631.   school "school" output.check
  632.   address output
  633.   new.block
  634.   note output
  635.   fin.entry
  636. FUNCTION {proceedings}
  637. { output.bibitem
  638.   format.editors output
  639.   editor format.key output                % special for
  640.   output.year.check                    % apalike
  641.   new.block
  642.   format.btitle "title" output.check
  643.   format.bvolume output
  644.   format.number.series output
  645.   address output                % for apalike
  646.   new.sentence                    % we always output
  647.   organization output                % a nonempty organization
  648.   publisher output                % here
  649.   new.block
  650.   note output
  651.   fin.entry
  652. FUNCTION {techreport}
  653. { output.bibitem
  654.   format.authors "author" output.check
  655.   author format.key output                % special for
  656.   output.year.check                    % apalike
  657.   new.block
  658.   format.title "title" output.check
  659.   new.block
  660.   format.tr.number output.nonnull
  661.   institution "institution" output.check
  662.   address output
  663.   new.block
  664.   note output
  665.   fin.entry
  666. FUNCTION {unpublished}
  667. { output.bibitem
  668.   format.authors "author" output.check
  669.   author format.key output                % special for
  670.   output.year.check                    % apalike
  671.   new.block
  672.   format.title "title" output.check
  673.   new.block
  674.   note "note" output.check
  675.   fin.entry
  676. FUNCTION {default.type} { misc }
  677. MACRO {jan} {"January"}
  678. MACRO {feb} {"February"}
  679. MACRO {mar} {"March"}
  680. MACRO {apr} {"April"}
  681. MACRO {may} {"May"}
  682. MACRO {jun} {"June"}
  683. MACRO {jul} {"July"}
  684. MACRO {aug} {"August"}
  685. MACRO {sep} {"September"}
  686. MACRO {oct} {"October"}
  687. MACRO {nov} {"November"}
  688. MACRO {dec} {"December"}
  689. MACRO {acmcs} {"ACM Computing Surveys"}
  690. MACRO {acta} {"Acta Informatica"}
  691. MACRO {cacm} {"Communications of the ACM"}
  692. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  693. MACRO {ibmsj} {"IBM Systems Journal"}
  694. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  695. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  696. MACRO {ieeetcad}
  697.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  698. MACRO {ipl} {"Information Processing Letters"}
  699. MACRO {jacm} {"Journal of the ACM"}
  700. MACRO {jcss} {"Journal of Computer and System Sciences"}
  701. MACRO {scp} {"Science of Computer Programming"}
  702. MACRO {sicomp} {"SIAM Journal on Computing"}
  703. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  704. MACRO {tods} {"ACM Transactions on Database Systems"}
  705. MACRO {tog} {"ACM Transactions on Graphics"}
  706. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  707. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  708. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  709. MACRO {tcs} {"Theoretical Computer Science"}
  710. FUNCTION {sortify}
  711. { purify$
  712.   "l" change.case$
  713. INTEGERS { len }
  714. FUNCTION {chop.word}
  715. { 's :=
  716.   'len :=
  717.   s #1 len substring$ =
  718.     { s len #1 + global.max$ substring$ }
  719.     's
  720.   if$
  721. %            There are three apalike cases: one person (Jones),
  722. %            two (Jones and de~Bruijn), and more (Jones et~al.).
  723. %            This function is much like format.crossref.editors.
  724. FUNCTION {format.lab.names}
  725. { 's :=
  726.   s #1 "{vv~}{ll}" format.name$
  727.   s num.names$ duplicate$
  728.   #2 >
  729.     { pop$ " et~al." * }
  730.     { #2 <
  731.     'skip$
  732.     { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  733.         { " et~al." * }
  734.         { " and " * s #2 "{vv~}{ll}" format.name$ * }
  735.       if$
  736.       if$
  737.     }
  738.   if$
  739. FUNCTION {author.key.label}
  740. { author empty$
  741.     { key empty$
  742.     { cite$ #1 #3 substring$ }
  743.     'key                    % apalike uses the whole key
  744.       if$
  745.     }
  746.     { author format.lab.names }
  747.   if$
  748. FUNCTION {author.editor.key.label}
  749. { author empty$
  750.     { editor empty$
  751.     { key empty$
  752.         { cite$ #1 #3 substring$ }
  753.         'key                % apalike uses the whole key
  754.       if$
  755.     { editor format.lab.names }
  756.       if$
  757.     }
  758.     { author format.lab.names }
  759.   if$
  760. FUNCTION {editor.key.label}
  761. { editor empty$
  762.     { key empty$
  763.     { cite$ #1 #3 substring$ }
  764.     'key            % apalike uses the whole key, no organization
  765.       if$
  766.     }
  767.     { editor format.lab.names }
  768.   if$
  769. FUNCTION {calc.label}      % this function came from ASTRON.BST (ARR)
  770. { type$ "book" =
  771.   type$ "inbook" =
  772.     'author.editor.key.label
  773.     { type$ "proceedings" =
  774.         'editor.key.label                       % apalike ignores organization
  775.         'author.key.label                       % for labeling and sorting
  776.       if$
  777.     }
  778.   if$
  779.   "\protect\astroncite{" swap$ * "}{"                   % these three lines are
  780.   *                                                     % for apalike, which
  781.   year field.or.null purify$ #-1 #4 substring$          % uses all four digits
  782.   *                       % the mathing closing "}" comes in at the reverse.pass
  783.   'label :=
  784. FUNCTION {sort.format.names}
  785. { 's :=
  786.   #1 'nameptr :=
  787.   s num.names$ 'numnames :=
  788.   numnames 'namesleft :=
  789.     { namesleft #0 > }
  790.     { nameptr #1 >
  791.     { "   " * }
  792.     'skip$
  793.       if$                        % apalike uses initials
  794.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't := % <= here
  795.       nameptr numnames = t "others" = and
  796.     { "et al" * }
  797.     { t sortify * }
  798.       if$
  799.       nameptr #1 + 'nameptr :=
  800.       namesleft #1 - 'namesleft :=
  801.     }
  802.   while$
  803. FUNCTION {sort.format.title}
  804. { 't :=
  805.   "A " #2
  806.     "An " #3
  807.       "The " #4 t chop.word
  808.     chop.word
  809.   chop.word
  810.   sortify
  811.   #1 global.max$ substring$
  812. FUNCTION {author.sort}
  813. { author empty$
  814.     { key empty$
  815.     { "to sort, need author or key in " cite$ * warning$
  816.       ""
  817.     { key sortify }
  818.       if$
  819.     }
  820.     { author sort.format.names }
  821.   if$
  822. FUNCTION {author.editor.sort}
  823. { author empty$
  824.     { editor empty$
  825.     { key empty$
  826.         { "to sort, need author, editor, or key in " cite$ * warning$
  827.           ""
  828.         }
  829.         { key sortify }
  830.       if$
  831.     { editor sort.format.names }
  832.       if$
  833.     }
  834.     { author sort.format.names }
  835.   if$
  836. FUNCTION {editor.sort}
  837. { editor empty$
  838.     { key empty$
  839.     { "to sort, need editor or key in " cite$ * warning$
  840.       ""
  841.     { key sortify }
  842.       if$
  843.     }
  844.     { editor sort.format.names }
  845.   if$
  846. %            apalike uses two sorting passes; the first one sets the
  847. %            labels so that the `a's, `b's, etc. can be computed;
  848. %            the second pass puts the references in "correct" order.
  849. %            The presort function is for the first pass. It computes
  850. %            label, sort.label, and title, and then concatenates.
  851. FUNCTION {presort}
  852. { calc.label
  853.   label sortify
  854.   "    "
  855.   type$ "book" =
  856.   type$ "inbook" =
  857.     'author.editor.sort
  858.     { type$ "proceedings" =
  859.     'editor.sort
  860.     'author.sort
  861.       if$
  862.     }
  863.   if$
  864.   #1 entry.max$ substring$    % for
  865.   'sort.label :=        % apalike
  866.   sort.label            % style
  867.   "    "
  868.   title field.or.null
  869.   sort.format.title
  870.   #1 entry.max$ substring$
  871.   'sort.key$ :=
  872. ITERATE {presort}
  873. SORT        % by label, sort.label, title---for final label calculation
  874. STRINGS { last.label next.extra }    % apalike labels are only for the text;
  875. INTEGERS { last.extra.num }        % there are none in the bibliography
  876. FUNCTION {initialize.extra.label.stuff}    % and hence there is no `longest.label'
  877. { #0 int.to.chr$ 'last.label :=
  878.   "" 'next.extra :=
  879.   #0 'last.extra.num :=
  880. FUNCTION {forward.pass}
  881. { last.label label =
  882.     { last.extra.num #1 + 'last.extra.num :=
  883.       last.extra.num int.to.chr$ 'extra.label :=
  884.     }
  885.     { "a" chr.to.int$ 'last.extra.num :=
  886.       "" 'extra.label :=
  887.       label 'last.label :=
  888.     }
  889.   if$
  890. FUNCTION {reverse.pass}       % this function came from ASTRON.BST (ARR)
  891. { next.extra "b" =
  892.     { "a" 'extra.label := }
  893.     'skip$
  894.   if$
  895.   label extra.label * "}" * 'label :=
  896.   extra.label 'next.extra :=
  897. EXECUTE {initialize.extra.label.stuff}
  898. ITERATE {forward.pass}
  899. REVERSE {reverse.pass}
  900. %                Now that the label is right we sort for real,
  901. %                on sort.label then year then title.  This is
  902. %                for the second sorting pass.
  903. FUNCTION {bib.sort.order}
  904. { sort.label
  905.   "    "
  906.   year field.or.null sortify
  907.   "    "
  908.   title field.or.null
  909.   sort.format.title
  910.   #1 entry.max$ substring$
  911.   'sort.key$ :=
  912. ITERATE {bib.sort.order}
  913. SORT        % by sort.label, year, title---giving final bibliography order
  914. FUNCTION {begin.bib}
  915. { preamble$ empty$                % no \etalchar in apalike
  916.     'skip$
  917.     { preamble$ write$ newline$ }
  918.   if$
  919.   "\begin{thebibliography}{}" write$ newline$        % no labels in apalike
  920. EXECUTE {begin.bib}
  921. EXECUTE {init.state.consts}
  922. ITERATE {call.type$}
  923. FUNCTION {end.bib}
  924. { newline$
  925.   "\end{thebibliography}" write$ newline$
  926. EXECUTE {end.bib}
  927.